<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<style>
.cot0, .cot1,.cot2,.cot3 {
	float: left;
	padding: 5px auto;
}

.cot1 {
	width: 650px;
}

.cot3 {
	width: 110px;
}

.cot0 {
	width: 30px;
	text-align: center;
}
</style>
<script type="text/javascript" language="JavaScript">

function CloseMySelf(sender) {
	var radios = document.getElementsByName("radioselect");
    var formValid = false;
    var i = 0;
    while (!formValid && i < radios.length) {
        if (radios[i].checked) formValid = true;
        i++;        
    }
    if (!formValid){ alert("Must check some option!");
    return formValid;}
    else
	var x;
	var y;
    try {
    	var radios = document.getElementsByName("radioselect");
    	var i = 0;
        while (i < radios.length) {
            if (radios[i].checked){
            	x=radios[i].value;
            	y=document.getElementById(x).value;
            }
            i++;        
        }
    }
    catch (err) {}
    window.opener.document.getElementById("siccode").value=x;
    window.opener.document.getElementById("typeofbusiness").value=y;
    window.open('','_self',''); 
    window.close(); 
    return true;
}
function closeWindow(){ 
    window.open('','_self',''); 
    window.close(); 
} 
</script>
<h1>Search Business Type</h1>
<form action="searchbusiness" method="POST">
	<div style="padding-top: 10px">
		Business Name: <input type="text" name="businessname"
			style="width: 220px; margin-right: 50px"> SIC Code: <input
			type="text" name="siccode" style="width: 50px;">

	</div>
	<div
		style="float: left; clear: both; display: block; padding: 15px 0px">
		<input class="button_css" type="submit" value="Search"> <input
			class="button_css" type="submit" value="None"> <input
			class="button_css" type="reset" value="Clear">
	</div>
</form>
<div style="display: block; float: left; clear: both">
	<ul>
		<li class="li_title">
			<div class="cot0">&nbsp</div>
			<div class="cot1">Business Name</div>
			<div class="cot3">SIC Code</div></li>
		<c:if test="${!empty businessList}">
		<form action="select.html" method="post" id="page" name="page" onsubmit="checkRadio()">
			<c:forEach items="${businessList}" var="business">
				<li>
					<div class="cot0" style="padding: 5px 2px">
						<input type="radio" name="radioselect" value="${business.sic}" />
					<input type="hidden" name="radioselect"  id="${business.sic}" value="${business.businessname}" />
					</div>
					<div class="cot1">${business.businessname}</div>
					<div class="cot2">${business.sic}</div>
			</c:forEach>
			</form>
		</c:if>
	</ul>
</div>
<div style="float: left; display: block; padding-top: 15px">
			<input type="submit" id="btSelect" value="Select"  class="button_css"  onclick="return CloseMySelf(this);" > <input
			type="submit" id="btEdit" value="Edit"  class="button_css" > <a href="" onclick="closeWindow();"><input  class="button_css" type="submit"
			id="btClose" value="Close"></a>
</div>
<div style="float:right; display: block; padding-top: 15px;">
	Page <input style="font-size: 12px; width: 35px; padding: 2px;"
		class="curpage" type="text" name="b" value="${curpage}" /> of <span
		class="nops">1</span>
</div>